package com.song.shop.controller;

import com.song.shop.rabbitmq.FanoutSend;
import com.song.shop.rabbitmq.HelloSender1;
import com.song.shop.rabbitmq.TopicSend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class RabbitMqController {
	
	@Autowired
    private HelloSender1 helloSender1;
    @Autowired
    private HelloSender1 helloSender2;
    @Autowired
    private TopicSend topicSend ; 
    @Autowired
    private FanoutSend fanoutSend ; 
    
    @RequestMapping(value="/helloSend")
    public String hello() {
    	helloSender1.send();
    	helloSender2.send();
    	return "success";
    }
    
    @RequestMapping(value = "/topicSend")
    public String topic(HttpServletRequest request) {

    	for (int i = 0 ; i< 10 ; i++) {
    		topicSend.send();
    	}
    	return "success";
    }
    /**
     *  订阅 fanout
     * @return
     */
    @RequestMapping(value = "/fanoutSend")
    public String Fanout() {
    	for (int i = 0 ; i< 10 ; i++) {
    		fanoutSend.send();
    	}
    	return "success";
    }


}
